<template>
	<view>
		<mescroll-body :sticky="true" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
			<view>
				<view class="head">
					<view class=" searchx_box" @click.stop="goSearch">
						<view class="flex justify-between margin-right-sm" @tap.stop="goSelectCity"
							style="line-height: 68rpx;">
							<image src="../../static/images/index/place.png"
								style="width: 27rpx;height: 37rpx;margin-top:15rpx"></image>
							<view class="localName text-white margin-left-sm">{{city}}</view>
						</view>
						<u-search class="flex-sub" placeholder="搜索你想要的陪陪" shape="round" disabled :show-action="false"
							height="76" :animation="true" bg-color="#212138" search-icon-color="#CFD8F4"
							placeholder-color="#CFD8F4">
						</u-search>
					</view>
				</view>
				<!-- <view class="sticky-tabs u-skeleton-rect">
				<me-tabs v-model="tabIndex" nameKey='gameName' :tabs="tabData" @change="tabChange"></me-tabs>
			</view> -->
				<!-- #ifdef H5 -->
				<view class="padding-lr" style="margin-top: 170rpx;">
				<!-- #endif -->
					<!-- #ifdef MP-WEIXIN -->
					<view class="padding-lr padding-top-xs" style="margin-top: 250rpx;">
					<!-- #endif -->
						<!-- #ifdef APP -->
						<view class="padding-lr padding-top-xs" style="margin-top: 200rpx;">
						<!-- #endif -->
							<swiper class="screen-swiper" style="height: 200rpx;" :circular="true" :autoplay="true"
								interval="5000" duration="800">
								<swiper-item v-for="(item,index) in swiperList" :key="index" @click="goNav(item.url)">
									<image :src="item.imageUrl"
										style="width: 100%;;height: 200rpx;border-radius: 24upx;">
									</image>
								</swiper-item>
							</swiper>
						</view>

					</view>
					<view class="margin-top-xs" style="color: #BFBFCB;">
						<u-grid :col="5" :border="false">
							<u-grid-item bg-color="#111224" v-for="(item,index) in gridData" :key='index'
								@tap="goNav(item.url)">
								<image :src="item.imageUrl" style="width: 80rpx;height: 80rpx;">
								</image>
								<view class="text-white margin-top-xs text-sm">{{item.name}}</view>
							</u-grid-item>
						</u-grid>
					</view>

					<!-- <view class="margin-lr margin-bottom" @click="getFastOrder()" v-if="shangxianSelect !='否'">
				<image :src="yuewanImage" style="width: 100%;height: 150upx;" mode="aspectFit"></image>
			</view> -->
					<view class="flex margin-lr justify-between margin-top-xs" v-if="bannerList.length!=0">
						<view @click="getPaihangbang(bannerList[0].url)">
							<image :src="bannerList[0].imageUrl" style="width: 339rpx;height: 166rpx;"></image>
						</view>
						<view @click="getFastOrder(bannerList[1].url)">
							<image :src="bannerList[1].imageUrl" style="width:339rpx ;height: 166rpx;"></image>
						</view>
					</view>
					<!-- 乐享低价 -->
					<view class="fubg" v-if="lowTaking.length">
						<view class="headtop">
							<view>
								<image
									src="https://pw.xianmxkj.com/file/uploadPath/2023/03/28/b45d453b4b68bc332aa57d98e18a67f9.png"
									style="width: 249rpx;height: 87rpx;"></image>
							</view>
							<view class="title_right" @tap="goLowTaking()">
								更多
								<image class="margin-left-sm" style="width: 14rpx;height: 24rpx;display: inline-block;"
									src="../../static/images/index/right.png"></image>
							</view>
						</view>
						<view class="headbot" style="">
							<view v-for="(item,index) in lowTaking" :key='index' @click="goOrder(item)"
								style="width: 200rpx;">
								<view class="u-relative">
									<image style="width: 200rpx;height: 200rpx;border-radius: 20rpx;"
										:src="item.avatar?item.avatar: '../../static/logo.png'">
									</image>
								</view>
								<view class="margin-top-xs text-white text-df text-cut" style="height: 40rpx;">
									{{item.userName}}
								</view>
								<view class="margin-top-xs flex align-center" style="color: #FBEA74;">
									<image style="display: inline-block;margin-right: 6upx;width: 30rpx;height: 30rpx;"
										src="../../static/images/index/jinbi.png"></image>
									<text class=" ">{{isVip? item.memberMoney :item.money}}币</text>/{{item.unit}}
								</view>
							</view>
						</view>
					</view>

					<view class="margin-top-xs">
						<ren-dropdown-filter :filterData='filterData' :border="false" :defaultIndex='defaultIndex'
							@onSelected='change'>
						</ren-dropdown-filter>
					</view>
					<view class="margin-lr-sm" v-if="orderList.length">
						<view class="bgbox" v-for="(item,index) in orderList" :key='index' @click="goOrder(item)">
							<view style="margin-top: -30rpx;position: relative;bottom: -6rpx;">
								<image :src="item.avatar?item.avatar: '../../static/logo.png'" mode="aspectFill"
									style="width: 230rpx;height: 260rpx;border-radius: 24rpx"></image>
								<view class="yuyinImg" @click.stop="playVoice(item.voiceIntroduce,item.isPlay,index)"
									v-if="item.voiceIntroduce">
									<view class="flex align-center box">
										<!-- 暂停 -->
										<image v-if="item.isPlay==false" src="../../static/jc-record/index.png" mode=""
											style="width: 40upx;height: 40upx;"></image>
										<!-- 播放 -->
										<image v-else src="../../static/jc-record/bof.png" mode=""
											style="width: 40upx;height: 40upx;"></image>

										<image src="../../static/jc-record/yuyin.png" mode=""
											style="width: 84upx;height: 32upx;margin: 0upx 10upx;"></image>
										<view v-if="item.sec">{{item.sec}}<text>"</text></view>
									</view>
								</view>
							</view>
							<view class="flex-sub margin-left padding-top-sm flex flex-direction justify-between">
								<view class="flex align-center justify-between">
									<view class="flex align-center ">
										<view class="margin-right-xs text-lg text-bold text-cut"
											style="display: inline-block;">
											{{item.userName}}
										</view>
										<view v-if="item.sex == 1" class="  margin-right-xs"
											style="display: inline-block;background:linear-gradient(-90deg, #174C6D, #33355F);;padding: 2upx 12upx;color: #6EE3FB;border-radius: 50rpx;">
											<u-icon name="man" color="#6EE3FB" size="24"></u-icon>
											{{item.age?item.age:0}}
										</view>
										<view v-if="item.sex == 2" class="  margin-right-xs"
											style="display: inline-block;background: linear-gradient(-90deg, #4F2B4B, #6735b1);padding: 2upx 12upx;color: #FB85FC;border-radius: 50rpx;">
											<u-icon name="woman" color="#FB85FC" size="24"></u-icon>
											{{item.age?item.age:0}}
										</view>
									</view>
									<view class="">
										<view class="text-sm" v-if="item.onLine==1">
											<view
												style="width: 10upx;height: 10upx;background: #1AD566;border-radius: 10upx;display: inline-block;margin: 0 8upx 4upx 0;">
											</view>
											在线
										</view>
										<view class="text-sm" v-else>
											<view
												style="width: 10upx;height: 10upx;background: #999999;border-radius: 10upx;display: inline-block;margin: 0 8upx 4upx 0;">
											</view>
											离线
										</view>
										<!-- <view class="text-sm" v-if="item.city" style="color: #FFFFFF;display: inline-block;">
									{{item.city}} {{juliSelect === '是' ? item.distance : ''}}
								</view> -->
									</view>

								</view>
								<view class="flex" v-if="item.label ">
									<view v-for="(ite,ind) in item.label" :key="ind">
										<image :src="ite" style="width: 98rpx;height: auto;margin-right: 5rpx;"
											mode="widthFix">
										</image>
									</view>
								</view>
								<view class="flex text-sm" style="color: #FFFFFF;">
									<view class="margin-right" v-if="item.orderScore">评分{{(item.orderScore).toFixed(2)}}
									</view>
									<view class="margin-right" v-else>暂无评分</view>
									<view v-if="item.count">{{item.count}}人已下单</view>
								</view>
								<view class="flex align-center justify-between">
									<view class="gambox">
										<view class="gamebox">
											<image :src="item.gameImg" mode="aspectFill" style="">
											</image>
											<view class="level">{{item.gameName}}</view>
										</view>
										<view class="mytit">{{item.myLevel}}</view>
									</view>
									<view style="color: #FBEA74;">
										<text
											class="text-lg text-bold">{{isVip? item.memberMoney :item.money }}</text>币/{{item.unit}}
									</view>
								</view>
							</view>
						</view>
					</view>
					<empty v-if="orderList.length == 0"></empty>
		</mescroll-body>
		<u-popup v-model="qingshow" mode="center" width="551rpx"
			bgColor="linear-gradient(23deg, #37225D 0%, #313035 89%)">
			<view class="text-center" style="padding: 50rpx 40rpx;">
				<image src="https://pw.xianmxkj.com/file/uploadPath/2023/11/24/54d953a59e236f79a87dd516d2316703.png"
					style="width: 192rpx;height: 174rpx;">
				</image>
				<view class="text-left text-26" style="width: 467rpx;margin: 50rpx auto;color: #BCB2D4;">
					为呵护未成年人健康成长平台推出青少年 模式，该模式下部分功能无法正常使用。请监护人主动选择，并设置监护密码
				</view>
				<view class="flex align-center justify-between">
					<view class="btnn" @click="gomoshi()">去开启</view>
					<view class="btnns" @tap="gbQs()">我知道了</view>
				</view>
			</view>
		</u-popup>

		<popup :show="popupshow" @closeT="popupshow = false" @sureT="sureT" :content="content"></popup>
		<couponTipsCom @closeCop="closeCop" @getMyNewCoupon="getMyNewCoupon" v-if="showCoupon" :list="couponList"
			:showCoupon="showCoupon" />
	</view>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import mescrollBody from "@/components/mescroll-uni/components/mescroll-body/mescroll-body.vue";
	import meTabs from "@/components/mescroll-uni/me-tabs/me-tabs.vue";
	import empty from '@/components/empty.vue'
	import popup from '@/components/popup.vue'
	import RenDropdownFilter from '@/components/ren-dropdown-filter/ren-dropdown-filter.vue'
	import couponTipsCom from '../../components/couponTipsCom/couponTipsCom.vue'

	export default {
		mixins: [MescrollMixin], // 使用mixin
		components: {
			mescrollBody,
			meTabs,
			empty,
			RenDropdownFilter,
			popup,
			couponTipsCom
		},
		data() {
			return {
				showCoupon: false, //是否显示新人优惠券
				couponList: [], //新人优惠券列表
				qingshow: false,
				popupshow: false,
				content: '',
				popupType: 0,
				juliSelect: '否',
				shangxianSelect: '否',
				defaultSelected: [],
				tabIndex: 0, // tab下标
				tabData: [{
					createTime: "",
					gameName: '推荐',
					gameImg: "",
					id: 0,
					status: 0,
					updateTime: "",
				}],
				IdStatus: 0,
				yueSelect: '否',
				swiperList: [],
				bannerList: [],
				gridData: [],
				lowTaking: [],

				value1: '',
				value2: '',
				value3: '',

				defaultIndex: [0, 0, 0],
				filterData: [
					[{
							label: '智能排序',
							value: '',
						},
						{
							label: '距离优先',
							value: 3,
						},
						{
							label: '人气优先',
							value: 2,
						},
						{
							label: '同城优先',
							value: 1,
						}
					],
					[{
							label: '不限性别',
							value: '',
						},
						{
							label: '限男生',
							value: 1,
						},
						{
							label: '限女生',
							value: 2,
						}
					],
					[{
							label: '不限价格',
							value: '',
						},
						{
							label: '从高到低',
							value: 'desc',
						},
						{
							label: '从低到高',
							value: 'asc',
						}
					],
				],

				city: '请选择城市',
				latitude: '',
				longitude: '',
				orderList: [],
				token: '',
				isVip: false,
				myId: uni.getStorageSync('userId') ? uni.getStorageSync('userId') : '',
				showModal: true,
				backgroundImage: '',
				tuiguang: '',
				invitationCode: '',
				arr: [],
				myFabu: '',
				fabuNumber: '',
				fabuPrice: '',
				yuewanFabu: '否',
				yuewanImage: '',
				invitationCode: "",
				tuiguang: '快来和我一起打游戏吧!',
				bgImg: '',
				isPlay: false,
				AUDIO: uni.createInnerAudioContext(),
				musicIndex: '',
			}
		},
		onShareAppMessage(res) {
			return {
				path: '/pages/index/index?invitation=' + this.invitationCode, //这是为了传参   onload(data){let id=data.id;} 
				title: this.tuiguang,
				imageUrl: this.backgroundImage
			}
		},
		/*
		 * uniapp微信小程序分享页面到微信朋友圈
		 */
		onShareTimeline(res) {
			return {
				path: '/pages/index/index?invitation=' + this.invitationCode, //这是为了传参   onload(data){let id=data.id;} 
				title: this.tuiguang,
				imageUrl: this.backgroundImage
			}
		},
		onLoad(e) {
			this.invitationCode = this.$queue.getData('invitationCode');
			this.shangxianSelect = this.$queue.getData('shangxianSelect');
			this.yuewanFabu = this.$queue.getData('yuewanFabu')
			this.yuewanImage = this.$queue.getData('yuewanImage')
			let that = this
			that.$Request.getT('/app/banner/selectBannerList?state=-1&classify=5').then(res => {
				if (res.code === 0) {
					that.backgroundImage = res.data[0].imageUrl;
				}
			});
			that.$Request.getT('/app/common/type/116').then(res => {
				if (res.code === 0) {
					if (res.data && res.data.value) {
						that.tuiguang = res.data.value;
					}
				}
			});
			that.$Request.getT('/app/common/type/308').then(res => { //快速派单图
				if (res.code == 0) {
					if (res.data && res.data.value) {
						that.yuewanImage = res.data.value
					}
				}
			});
			that.getClassfly()

			if (that.myId) {
				that.$Request.getT('/app/common/type/235').then(res => { //新订单通知
					if (res.code == 0) {
						if (res.data && res.data.value) {
							that.arr.push(res.data.value)
						}
					}
				})
				that.$Request.getT('/app/common/type/236').then(res => { //微信退款
					if (res.code == 0) {
						if (res.data && res.data.value) {
							that.arr.push(res.data.value)
						}
					}
				})
				that.$Request.getT('/app/common/type/240').then(res => { //消息推送
					if (res.code == 0) {
						if (res.data && res.data.value) {
							that.arr.push(res.data.value)
						}
					}
				})
				this.$Request.getT('/app/common/type/116').then(res => { //分享文字
					if (res.code === 0) {
						if (res.data && res.data.value) {
							this.tuiguang = res.data.value;
						}
					}
				});
				this.$Request.getT('/app/common/type/313').then(res => { //分享图片配置 
					if (res.code === 0) {
						if (res.data && res.data.value) {
							this.bgImg = res.data.value;
						}
					}
				});
			}

			uni.getLocation({
				type: 'gcj02',
				geocode: true, //设置该参数为true可直接获取经纬度及城市信息
				success: function(res) {
					console.log(res, '地理位置')
					that.latitude = res.latitude
					that.longitude = res.longitude
					uni.setStorageSync('latitude', res.latitude)
					uni.setStorageSync('longitude', res.longitude)

					// #ifdef APP-PLUS
					that.city = res.address.city
					uni.setStorageSync('city', res.address.city)
					let data = {
						num: 1,
						size: 10
					}
					that.getData(data)
					// #endif

					// #ifdef H5
					that.selectCity(that.longitude, that.latitude);
					// #endif

					// #ifdef MP-WEIXIN
					// that.selectCity(that.longitude, that.latitude);
					uni.request({
						url: 'https://apis.map.qq.com/ws/geocoder/v1/?location=' + that.latitude +
							',' + that.longitude + '&key=4EKBZ-FBNWK-IWJJB-AYSHU-6RB2V-JJFP6',
						success(re) {
							if (re.statusCode === 200) {
								let citydata = re.data.result.address_component.city
								console.log("获取城市名称成功", citydata)
								that.city = citydata ? citydata : '未知'
								uni.setStorageSync('city', citydata)
								let data = {
									num: 1,
									size: 10
								}
								that.getData(data)
							} else {
								console.log("获取信息失败，请重试！")
							}
						}
					});
					// #endif
				},
				fail: function() {
					console.log('获取地址失败')
				}
			})
			// #ifdef MP-WEIXIN
			if (e.scene) {
				const scene = decodeURIComponent(e.scene);
				this.$queue.setData('inviterCode', scene.split(',')[0]);
			}
			// #endif

			// 获取邀请码保存到本地
			if (e.invitation) {
				that.$queue.setData('inviterCode', e.invitation);
			}

			//语音自然播放结束
			that.AUDIO.onEnded((res) => {
				console.log("this.musicIndex___:" + that.musicIndex)
				let musicIndexs = that.musicIndex;
				if (musicIndexs != '') {
					that.orderList[musicIndexs].isPlay = false;
				} else {
					that.orderList[0].isPlay = false;
				}
			});
		},
		onShow() {
			this.yuewanImage = this.$queue.getData('yuewanImage')
			this.juliSelect = this.$queue.getData('juliSelect');
			this.yueSelect = this.$queue.getData('yueSelect');
			this.fabuNumber = this.$queue.getData('fabuNumber');
			this.yuewanFabu = this.$queue.getData('yuewanFabu')
			this.fabuPrice = this.$queue.getData('fabuPrice')
			let that = this
			that.city = uni.getStorageSync('city') ? uni.getStorageSync('city') : '请选择城市'
			that.getBannerList()
			that.getbannerList1()
			that.getGrid()
			that.getLowTaking()
			that.getUserFabu()
			that.token = uni.getStorageSync('token')
			if (uni.getStorageSync('token')) {
				that.getUserInfo();
				that.getIsVip()
				that.getRenZheng();
			}
			that.myId = uni.getStorageSync('userId')
			console.log(that.showModal, '------', that.myId)
			// #ifdef MP-WEIXIN
			//订阅
			if (that.myId) {
				if (this.showModal) {
					setTimeout(d => {
						this.openMsg()
					}, 2000)
				}
			}
			// #endif
		},
		onHide() {
			this.AUDIO.stop();
			let musicIndexs = this.musicIndex;
			if (musicIndexs != '') {
				this.orderList[musicIndexs].isPlay = false;
			}
		},
		methods: {
			closeCop() {
				this.showCoupon = false
			},
			//领取优惠券
			getMyNewCoupon() {
				uni.showLoading({
					title: '领取中'
				})
				this.$Request.post('/app/selfCouponUser/getNewUserCoupon').then(res => {
					if (res.status == 0) {
						uni.hideLoading()
						this.showCoupon = false
						uni.showToast({
							title: '领取成功'
						})
					} else {
						uni.hideLoading()
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			},
			//获取新人优惠券列表
			getNewCouponList() {
				this.$Request.getT('/app/common/type/818').then(res => {
					if (res.code == 0) {
						if (res.data && res.data.couponList) {
							if (res.data.couponList.length > 0) {
								this.couponList = res.data.couponList
								this.showCoupon = true
							}

						}
					}
				});
			},
			//获取vip状态
			getIsVip() {
				this.$Request.get("/app/UserVip/isUserVip").then(res => {
					if (res.code == 0) {
						this.isVip = res.data
						uni.setStorageSync('isVIP', res.data)
					}
				});
			},
			gbQs() {
				this.$Request.postT('/app/user/iKnow').then(res => {
					if (res.code == 0) {
						this.qingshow = false;
					} else {
						this.$queue.showToast(res.msg);
					}
				});
			},
			gomoshi() {
				//跳转青少年模式
				uni.navigateTo({
					url: '/package/pages/paihangbang/moshi'
				})
			},
			// 播放语音
			playVoice(voiceIntroduce, isPlay, index) {
				this.isPlay = this.orderList[index].isPlay
				this.AUDIO.src = voiceIntroduce;
				if (this.isPlay == true) {
					this.AUDIO.stop();

					this.orderList[index].isPlay = false
				} else {
					let musicIndexs = this.musicIndex;
					if (musicIndexs != '') {
						this.orderList[musicIndexs].isPlay = false;
					} else if (musicIndexs == 0) {
						this.orderList[0].isPlay = false;
					}
					this.musicIndex = index;
					this.AUDIO.stop();

					this.AUDIO.play();
					this.orderList[index].isPlay = true
				}
				// this.isPlay = !this.isPlay;
			},
			getUserFabu() {
				this.$Request.get("/app/fastOrder/selectMyFastCount").then(res => {
					if (res.code == 0) {
						this.myFabu = res.data
						uni.setStorageSync("myFabu", res.data)
					}
				});
			},
			sureT() {
				this.popupshow = false
				if (this.popupType == 0) {
					uni.navigateTo({
						url: '/package/pages/matching/matching'
					})
				} else if (this.popupType == 1) {
					let that = this
					wx.requestSubscribeMessage({
						tmplIds: that.arr,
						success(re) {
							console.log(JSON.stringify(re), '++++++++++++++')
							var datas = JSON.stringify(re);
							if (datas.indexOf("accept") != -1) {
								console.log(re)
								// uni.setStorageSync('sendMsg', true)
							}
						},
						fail: (res) => {
							console.log(res)
						}
					})
					that.showModal = false
				}

			},
			//判断用户是否已发布过订单
			getFastOrder() {
				let token = this.$queue.getData('token');
				if (token) {
					this.$Request.get("/app/fastOrder/selectFastOrder").then(res => {
						if (res.code == 0) {
							if (res.data != null) {
								uni.navigateTo({
									url: '/package/pages/matching/orderDeatil'
								})
							} else {
								if (this.yuewanFabu == '是') {
									if (this.myFabu < this.fabuNumber) {
										var num = this.fabuNumber - this.myFabu;
										this.content = '每日免费次数还剩余：' + num + '次，是否继续发布',
											this.popupType = 0
										this.popupshow = true

										return
									}
									if (this.myFabu >= this.fabuNumber) {
										this.content = '今日免费发布次数已完，发布需要支付' + this.fabuPrice + '金币,是否继续发布',
											this.popupType = 0
										this.popupshow = true

										return
									}
								} else {
									uni.navigateTo({
										url: '/package/pages/matching/matching'
									})
								}
							}
						}
					});

				} else {
					uni.navigateTo({
						url: '/pages/public/login'
					});
				}

			},
			getPaihangbang(url) {
				let token = this.$queue.getData('token');
				if (token) {
					uni.navigateTo({
						url: url
					})
					// uni.navigateTo({
					// 	url: '/package/pages/paihangbang/index'
					// })
				} else {
					uni.navigateTo({
						url: '/pages/public/login'
					});
				}
			},
			getUserInfo() {
				this.$Request.get("/app/user/selectUserById").then(res => {
					if (res.code == 0) {
						this.invitationCode = res.data.invitationCode
						if (!res.data.isNewUser) {
							this.getNewCouponList()
						}
						if (!res.data.babyModel) {
							this.qingshow = true;
						} else if (res.data.babyModel == 1) {
							uni.reLaunch({
								url: '/package/pages/paihangbang/moshi'
							})
						}
					}
				});
			},
			//检测是否为陪玩官
			getRenZheng() {
				this.$Request.get("/app/userCertification/queryInsert").then(res => {
					if (res.code == 0) {
						// 0审核中 1通过 2拒绝 
						if (res.data == null) {
							this.IdStatus = 0 //未实名
						} else if (res.data.status == 0) {
							this.IdStatus = 1 //审核中
						} else if (res.data.status == 1) {
							this.IdStatus = 2 //已实名
						} else if (res.data.status == 2) {
							this.IdStatus = 3 //已拒绝
						}
					}
				});
			},
			selectCity(longitude, latitude) {
				this.$Request.get('/app/Login/selectCity?lat=' + latitude + '&lng=' + longitude).then(res => {
					if (res.code == 0) {
						this.city = res.data ? res.data : '未知'
						uni.setStorageSync('city', res.data)
						let data = {
							num: 1,
							size: 10
						}
						this.getData(data)
					}
				});
			},
			// 开启订阅消息
			openMsg() {
				console.log('订阅消息')
				var that = this
				uni.getSetting({
					withSubscriptions: true, //是否获取用户订阅消息的订阅状态，默认false不返回
					success(ret) {
						console.log(ret.subscriptionsSetting, '------------------')
						// if (ret.subscriptionsSetting.itemSettings && Object.keys(ret.subscriptionsSetting.itemSettings).length == 2) {
						if (ret.subscriptionsSetting.itemSettings) {
							uni.setStorageSync('sendMsg', true)
							uni.openSetting({ // 打开设置页 
								success(rea) {
									console.log(rea.authSetting)
								}
							});
						} else { // 用户没有点击“总是保持以上，不再询问”则每次都会调起订阅消息
							console.log(99999)
							uni.setStorageSync('sendMsg', false)
							that.content = '为了更好的体验,请绑定消息推送'
							that.popupType = 1
							that.popupshow = true

						}
					}
				})
			},

			/*下拉刷新的回调 */
			downCallback() {
				// 这里加载你想下拉刷新的数据, 比如刷新轮播数据
				// loadSwiper();
				// 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
				// this.$refs.uDropdown.close();
				this.mescroll.resetUpScroll()
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				// console.log(page,'*************')
				this.getData(page)
			},
			setMorKm(m) {
				var n = ''
				if (m) {
					if (m >= 1000) {
						n = (m / 1000).toFixed(0) + 'km'
					} else {
						n = parseInt(m) + 'm'
					}
				} else {
					n = '0m'
				}
				return n
			},
			getData(page) {
				let curTab = this.tabData[this.tabIndex].id
				let num
				if (this.tabIndex == 0) {
					num = 0
				} else {
					num = 2
				}
				let data = {
					id: curTab,
					page: page.num,
					limit: page.size,
					isRecommend: num,
					condition: this.value1, //智能优选
					sex: this.value2, //不限男女
					by: this.value3, //价格
					latitude: uni.getStorageSync('latitude') ? uni.getStorageSync('latitude') : '',
					longitude: uni.getStorageSync('longitude') ? uni.getStorageSync('longitude') : '',
					city: this.city
				}
				// console.log(data)
				if (this.token) {
					this.$Request.get("/app/orderTaking/queryTaking", data).then(res => {
						this.mescroll.endBySize(res.data.list.length, res.data.list)
						if (res.code == 0) {
							if (page.num == 1) {
								this.orderList = [];
							}
							res.data.list.forEach(d => {
								d.isPlay = false
								if (d.label) {
									d.label = d.label.split(',')
								}
								d.distance = this.setMorKm(d.distance);
								this.orderList.push(d);
							});
						}
						this.mescroll.endSuccess(res.data.list.length); // 隐藏加载状态栏
					}).catch(() => {
						//联网失败, 结束加载
						this.mescroll.endErr();
					});
				} else {
					this.$Request.get("/app/orderTaking/queryTakings", data).then(res => {
						this.mescroll.endBySize(res.data.list.length, res.data.list)
						if (res.code == 0) {

							if (page.num == 1) {
								this.orderList = [];
							}
							res.data.list.forEach(d => {
								d.isPlay = false
								if (d.label) {
									d.label = d.label.split(',')
								}
								d.distance = this.setMorKm(d.distance);
								this.orderList.push(d);
							});
						}
						this.mescroll.endSuccess(res.data.list.length); // 隐藏加载状态栏
					}).catch(() => {
						//联网失败, 结束加载
						this.mescroll.endErr();
					});
				}
				// this.getClassfly()
				// this.getBannerList()
				// this.getbannerList1()
				// this.getGrid()
				// this.getLowTaking()

			},
			// 切换菜单
			tabChange() {
				if (uni.getStorageSync('sendMsg')) {
					console.log('授权+1')
					wx.requestSubscribeMessage({
						tmplIds: this.arr,
						success(re) {
							console.log(JSON.stringify(re), 111111111111)
							var datas = JSON.stringify(re);
							if (datas.indexOf("accept") != -1) {
								console.log(re)
							}
						},
						fail: (res) => {
							console.log(res)
						}
					})
				}
				this.defaultIndex = [0, 0, 0]
				// this.$refs.uDropdown.close();
				// this.orderList = []; // 置空列表,显示加载进度条
				this.mescroll.resetUpScroll()
			},
			// 获取游戏类型
			getClassfly() {
				this.$Request.get("/app/appGame/queryGameName").then(res => {
					if (res.code == 0) {
						this.tabData = [{
							createTime: "",
							gameName: '推荐',
							gameImg: "",
							id: 0,
							status: 0,
							updateTime: "",
						}]
						this.tabData = [...this.tabData, ...res.data]

					}
				});
			},
			//获取轮播图
			getBannerList() {
				this.$Request.get("/app/banner/selectBannerList", {
					classify: 1
				}).then(res => {
					if (res.code == 0) {
						this.swiperList = res.data
					}
				});
			},
			//获取排行榜  约玩
			getbannerList1() {
				this.$Request.get("/app/banner/selectBannerList", {
					classify: 7
				}).then(res => {
					if (res.code == 0) {
						this.bannerList = res.data
					}
				});
			},
			// 获取金刚区分类
			getGrid() {
				this.$Request.get("/app/banner/selectBannerList", {
					classify: 2
				}).then(res => {
					if (res.code == 0) {
						this.gridData = res.data
					}
				});
			},
			// 乐享低价
			getLowTaking() {
				this.$Request.get("/app/orderTaking/queryLowTaking").then(res => {
					if (res.code == 0) {
						this.lowTaking = res.data
					}
				});
			},
			// 筛选
			change(e) {
				this.value1 = e[0][0].value
				this.value2 = e[1][0].value
				this.value3 = e[2][0].value
				this.page = 1;
				this.mescroll.resetUpScroll()
			},
			// 选择城市
			goSelectCity() {
				uni.navigateTo({
					url: '/pages/index/citys/citys'
				});
			},
			// 乐享低价
			goLowTaking() {
				uni.navigateTo({
					url: '/pages/index/game/lowTaking'
				});
			},
			// 跳转游戏列表
			goNav(url) {
				if (uni.getStorageSync('sendMsg')) {
					console.log('授权+1')
					wx.requestSubscribeMessage({
						tmplIds: this.arr,
						success(re) {
							console.log(JSON.stringify(re), 111111111111)
							var datas = JSON.stringify(re);
							if (datas.indexOf("accept") != -1) {
								console.log(re)
							}
						},
						fail: (res) => {
							console.log(res)
						}
					})
				}
				if (url.indexOf('/pages/') !== -1 || url.indexOf('/my/') !== -1) {
					uni.navigateTo({
						url
					});
				} else {
					//#ifndef H5
					uni.navigateTo({
						url: '/pages/index/webView?url=' + url
					});
					//#endif
					//#ifdef H5
					window.location.href = url;
					//#endif
				}
			},
			// 跳转搜索
			goSearch() {
				if (uni.getStorageSync('sendMsg')) {
					console.log('授权+1')
					wx.requestSubscribeMessage({
						tmplIds: this.arr,
						success(re) {
							console.log(JSON.stringify(re), 111111111111)
							var datas = JSON.stringify(re);
							if (datas.indexOf("accept") != -1) {
								console.log(re)
							}
						},
						fail: (res) => {
							console.log(res)
						}
					})
				}
				uni.navigateTo({
					url: '/pages/index/search/index'
				});
			},
			// 跳转订单
			goOrder(e) {
				console.log('授权', uni.getStorageSync('sendMsg'))
				if (uni.getStorageSync('sendMsg')) {
					console.log('授权+1')
					wx.requestSubscribeMessage({
						tmplIds: this.arr,
						success(re) {
							console.log(JSON.stringify(re), 111111111111)
							var datas = JSON.stringify(re);
							if (datas.indexOf("accept") != -1) {
								console.log(re)
							}
						},
						fail: (res) => {
							console.log(res)
						}
					})
				}
				if (this.token) {
					uni.navigateTo({
						url: '/pages/index/game/order?id=' + e.id + '&fenX=0'
					});
				} else {
					uni.navigateTo({
						url: '/pages/public/login'
					});
				}

			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #111224;
	}

	.head {
		// #28183e
		// background: linear-gradient(to left, #552775 20%,#552775 30%,#28183e 50%);
		// background-image: url('https://pw.xianmxkj.com/file/uploadPath/2023/03/20/c3e50814c6bb43cdeee6e046c93eae77.png');
		background-image: url('https://pw.xianmxkj.com/file/uploadPath/2023/03/21/c14daf6709e386c8236908f1f61db8ef.png');
		background-size: 100% 100%;
		position: fixed;
		// border-radius: 0 0 50rpx 50rpx;
		left: 0;
		right: 0;
		z-index: 999;
		/* #ifdef H5 */
		top: 0;
		padding-top: 30rpx;
		height: 170rpx;
		/* #endif */
		/* #ifdef MP-WEIXIN */
		top: 0;
		height: 250rpx;
		padding-top: 140rpx;
		// margin-top: ;
		/* #endif */
		/* #ifdef APP */
		top: 0;
		height: 190rpx;
		padding-top: 80rpx;
		/* #endif */
	}

	.searchx_box {

		// margin-top: 120rpx;
		// height: 200rpx;

		// background-image: url('https://pw.xianmxkj.com/file/uploadPath/2023/03/21/c14daf6709e386c8236908f1f61db8ef.png');
		padding: 20rpx 30rpx;
		display: flex;

	}

	.fubg {
		background-image: url('https://pw.xianmxkj.com/file/uploadPath/2023/03/20/4808ec8db553132571d0205506157c63.png');
		background-size: 100% 100%;
		margin: 25rpx 25rpx 0 25rpx;
		padding: 40rpx 30rpx 30rpx;
		position: relative;

		// margin-lr-sm padding-sm radius 
		.headtop {
			display: flex;
			justify-content: space-between;
			align-items: center;
			color: #FFFFFF;
			padding-bottom: 20rpx;
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			z-index: 99;

			.title_right {
				margin-right: 30rpx;
				margin-top: 10rpx;
			}
		}

		.headbot {
			overflow: hidden;
			display: flex;
			justify-content: space-between;
			padding-top: 70rpx;
		}
	}


	.bgbox {
		background-color: #291B3D;
		display: flex;
		justify-content: space-between;
		margin-top: 60rpx;
		padding: 0 20rpx 30rpx 20rpx;
		border-radius: 24upx;
		position: relative;
	}


	// .sticky-tabs {
	// 	z-index: 990;
	// 	position: sticky;
	// 	top: var(--window-top);
	// 	// background-color: #fff;
	// }


	/* // 使用mescroll-uni,则top为0 */
	// .mescroll-uni,
	// /deep/.mescroll-uni {
	// 	.sticky-tabs {
	// 		top: 0;
	// 	}
	// }

	// .demo-tip {
	// 	padding: 18upx;
	// 	font-size: 24upx;
	// 	text-align: center;
	// }

	.yuyinImg {
		width: 230upx;
		height: 60upx;
		text-align: center;
		line-height: 60upx;
		// background: #FFFFFF;
		// border-radius: 16upx;
		color: #FFFFFF;
		border-radius: 0rpx 0rpx 24rpx 24rpx;
		background: #523E80;
		margin-top: -10rpx;
		position: absolute;
		bottom: 0;
		left: 0rpx;
		right: 0;
	}

	.yuyinImg .box {
		width: 100%;
		text-align: center;
		justify-content: space-between;
		padding: 0 15rpx;
	}

	.gambox {
		width: fit-content;
		line-height: 39upx;
		background: linear-gradient(-90deg, #261d44 0%, #58287b 100%);
		border-radius: 24rpx 0 0 24rpx;
		display: flex;
		align-items: center;

		.gamebox {
			display: flex;
			align-items: center;
			background-image: url('https://pw.xianmxkj.com/file/uploadPath/2023/03/22/9c9581055662f648645300a662645892.png');
			background-size: 100% 100%;
			background-repeat: no-repeat;
			padding-right: 20rpx;
			border-radius: 24rpx 0 0 24rpx;
			position: relative;
			font-size: 24rpx;

			image {
				width: 47rpx;
				height: 43rpx;
				border-radius: 50%;
				position: absolute;
				top: 0;
				left: -10rpx;
			}

			.level {
				margin-left: 44rpx;
				font-size: 24rpx;

			}
		}

		.mytit {
			padding-right: 20rpx;
			max-width: 100rpx;
			// width: 110rpx;
			margin-left: 10rpx;
			font-size: 24rpx;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 1;
			overflow: hidden;

		}
	}

	.btnn {
		width: 220rpx;
		height: 70rpx;
		background: #F386BD;
		border-radius: 35rpx;
		text-align: center;
		line-height: 70rpx;

	}

	.btnns {
		width: 220rpx;
		height: 70rpx;
		background: #A671F7;
		border-radius: 35rpx;
		text-align: center;
		line-height: 70rpx;
	}
</style>